/* 根据剧本ID 获取 对应的目录  */

import { http } from "@/utils/http";

const getPcToken = () => {
  return localStorage.getItem("pcToken");
};
const baseProxy = import.meta.env.VITE_BASEPROXY;

/** 根据剧本ID 获取对应的章节目录 */
export const getDirectoryById = (id: number) => {
  return http.request<any>(
    "post",
    `${baseProxy}/acgDirectory/queryDirectory`,
    {
      data: {
        scriptId: id
      }
    },
    {
      headers: {
        pcToken: getPcToken()
      }
    }
  );
};

/** 更新目录 */
export const updateDirectory = (item: object) => {
  return http.request<any>(
    "post",
    `${baseProxy}/acgDirectory/updateDirectory`,
    {
      data: item
    },
    {
      headers: {
        pcToken: getPcToken()
      }
    }
  );
};
/** 删除目录 */
export const delDirectory = (id: number) => {
  return http.request<any>(
    "post",
    `${baseProxy}/acgDirectory/deleteDirectory`,
    {
      data: {
        id: id
      }
    },
    {
      headers: {
        pcToken: getPcToken()
      }
    }
  );
};
/** 新建目录 */
export const addDirectory = (item: object) => {
  return http.request<any>(
    "post",
    `${baseProxy}/acgDirectory/createDirectory`,
    {
      data: item
    },
    {
      headers: {
        pcToken: getPcToken()
      }
    }
  );
};
